package com.controller;

import com.common.Result;
import com.entity.Topic;
import com.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * User的路由接口服务
 * 
 * @author 
 *
 */
@RestController
@RequestMapping("pcApi")
public class TopicController {

	/** UserService服务 */
	@Autowired
	private TopicService topicService;


	/**
	 * 分页查询
	 * @param bean
	 * @return
	 */
	@ResponseBody
	@PostMapping(value = "/topic/create", produces = {"application/json;charset=UTF-8"})
	public Result create(@RequestBody Topic bean){
		return topicService.create(bean);
	}
	/**
	 * 通过id查询User数据的方法
	 * @param id
	 * @return
	 */
	@ResponseBody
	@PostMapping(value = "/topic/{id}", produces = {"application/json;charset=UTF-8"})
	public Topic findOne(@PathVariable(name="id") int id) {
		return topicService.findOne(id);
	}

	/**
	 * 分页查询
	 * @param bean
	 * @return
	 */
	@ResponseBody
	@PostMapping(value = "/topic/index", produces = {"application/json;charset=UTF-8"})
	public Result index(@RequestBody Topic bean){
		return topicService.index(bean);
	}

	/**
	 * 推荐专题查询
	 * @param bean
	 * @return
	 */
	@ResponseBody
	@PostMapping(value = "/topic/recommend", produces = {"application/json;charset=UTF-8"})
	public Result recommend(@RequestBody Topic bean){
		return topicService.recommend(bean);
	}

	/**
	 * 搜索专题
	 * @param bean
	 * @return
	 */
	@ResponseBody
	@PostMapping(value = "/topic/search", produces = {"application/json;charset=UTF-8"})
	public Result search(@RequestBody Topic bean){
		return topicService.search(bean);
	}


}
